package com.zc.microservice.system.core.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * swagger配置
 *
 * @author zcj
 * @version 1.0.0
 * @date 2022/5/13 10:47
 */
@Configuration(proxyBeanMethods = false)
@EnableOpenApi
public class SwaggerConfig {

    @Value(value = "${com.zc.swagger.enable:true}")
    private Boolean enable;

    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.OAS_30)
                .pathMapping("/")
                .enable(this.enable)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.zc.microservice.system"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("系统管理API")
                .description("gateway-server")
                .contact(new Contact("系统管理API", "www.zhangchunjia.com", "123@qq.com"))
                .version("1.0.0")
                .build();
    }
}